package com.geping.etl.common.controller;

import com.geping.etl.common.dto.*;
import com.geping.etl.common.service.SynBxSysUsersService;
import com.geping.etl.common.vo.BxResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @Author jianfeng.zhu
 * @Description 同步北京现代服务方接收接口
 * @Date 17:05 2021/9/1
 **/
@RestController
@RequestMapping("/bx/userapi")
@Slf4j
@Api(tags = "北京现代账户信息同步接口")
public class SynBxSysUsersController {

    @Resource
    private SynBxSysUsersService synBxSysUsersService;

    @RequestMapping(value = "/createAccount", method= RequestMethod.POST)
    @ApiOperation(value = "北现新增账户同步接口", notes = "北现新增账户同步接口")
    public BxResponseVo createAccount(@RequestBody @Valid BxSysUserDto bxSysUserDto){
        //添加请求日志
        log.info("createAccount start, bxSysUserDto = {}", bxSysUserDto);

        //调用service方法
        BxResponseVo bxResponseVo = synBxSysUsersService.createAccount(bxSysUserDto);

        //添加返回日志
        log.info("createAccount end, bxResponseVo = {}", bxResponseVo);

        return bxResponseVo;
    }


    @RequestMapping(value = "/deleteAccount", method= RequestMethod.POST)
    @ApiOperation(value = "北现删除账户同步接口", notes = "北现删除账户同步接口")
    public BxResponseVo deleteAccount(@RequestBody @Valid BxDeleteUserDto bxDeleteUserDto){
        //添加请求日志
        log.info("deleteAccount start, bxDeleteUserDto = {}", bxDeleteUserDto);

        //调用service方法
        BxResponseVo bxResponseVo = synBxSysUsersService.deleteAccount(bxDeleteUserDto);

        //添加返回日志
        log.info("deleteAccount end, bxResponseVo = {}", bxResponseVo);

        return bxResponseVo;
    }

    @RequestMapping(value = "/enableAccount", method= RequestMethod.POST)
    @ApiOperation(value = "北现生效账户同步接口", notes = "北现生效账户同步接口")
    public BxResponseVo enableAccount(@RequestBody @Valid BxEnableUserDto bxEnableUserDto){
        //添加请求日志
        log.info("enableAccount start, bxEnableUserDto = {}", bxEnableUserDto);

        //调用service方法
        BxResponseVo bxResponseVo = synBxSysUsersService.enableAccount(bxEnableUserDto);

        //添加返回日志
        log.info("enableAccount end, bxResponseVo = {}", bxResponseVo);

        return bxResponseVo;
    }


    @RequestMapping(value = "/disableAccount", method= RequestMethod.POST)
    @ApiOperation(value = "北现失效账户同步接口", notes = "北现失效账户同步接口")
    public BxResponseVo disableAccount(@RequestBody @Valid BxDisableUserDto bxDisableUserDto){
        //添加请求日志
        log.info("disableAccount start, bxDisableUserDto = {}", bxDisableUserDto);

        //调用service方法
        BxResponseVo bxResponseVo = synBxSysUsersService.disableAccount(bxDisableUserDto);

        //添加返回日志
        log.info("disableAccount end, bxResponseVo = {}", bxResponseVo);

        return bxResponseVo;
    }


    @RequestMapping(value = "/updateAccount", method= RequestMethod.POST)
    @ApiOperation(value = "北现修改账户同步接口", notes = "北现修改账户同步接口")
    public BxResponseVo updateAccount(@RequestBody @Valid BxSysUserUpdateDto bxSysUserUpdateDto){
        //添加请求日志
        log.info("updateAccount start, bxSysUserUpdateDto = {}", bxSysUserUpdateDto);

        //调用service方法
        BxResponseVo bxResponseVo = synBxSysUsersService.updateAccount(bxSysUserUpdateDto);

        //添加返回日志
        log.info("updateAccount end, bxResponseVo = {}", bxResponseVo);

        return bxResponseVo;
    }

    @RequestMapping(value = "/changePassword", method= RequestMethod.POST)
    @ApiOperation(value = "北现修改密码账户同步接口", notes = "北现修改密码账户同步接口")
    public BxResponseVo changePassword(@RequestBody @Valid BxPasswordUpdateUserDto bxPasswordUpdateUserDto){
        //添加请求日志
        log.info("changePassword start, bxPasswordUpdateUserDto = {}", bxPasswordUpdateUserDto);

        //调用service方法
        BxResponseVo bxResponseVo = synBxSysUsersService.changePassword(bxPasswordUpdateUserDto);

        //添加返回日志
        log.info("changePassword end, bxResponseVo = {}", bxResponseVo);

        return bxResponseVo;
    }

    @RequestMapping(value = "/updateRole",method = RequestMethod.POST)
    @ApiOperation(value = "北现用户角色同步接口",notes = "北现用户角色同步接口")
    public BxResponseVo updateRole(@RequestBody @Valid BxUpdateRoleDto bxUpdateRoleDto){
        //添加请求日志
        log.info("updateRole start, bxUpdateRoleDto = {}",bxUpdateRoleDto);

        //调用service方法
        BxResponseVo bxResponseVo = synBxSysUsersService.updateRole(bxUpdateRoleDto);

        //添加返回日志
        log.info("updateRole end, bxResponseVo = {}", bxResponseVo);

        return bxResponseVo;
    }
}
